#include <cstdio>

#define MAX_N 9999


inline bool get_int (int &n)
{
	return scanf("%d", &n) == 1;
}

inline void put_int (int &n)
{
	printf("%d\n", n);
}


struct Node
{
	int value;
	Node *prev, *next;

	inline void set (int v, Node *p, Node *n) {
		value = v;
		prev = p;
		next = n;
	}

	inline void set (int v) {
		set (v, 0, 0);
	}
};


struct List
{
	Node first[MAX_N], *last;

	inline void clear () {last = first;}

	inline void push (int v) {last->set(v); ++last;}

	inline void push_sorted (int v, Node *n) {
		if (v < n->value) {
			while (n->prev && v < n->prev->value)
				n = n->prev;
			last->set(v, n->prev, n);
			n->prev = last;
			if (last->prev)
				last->prev->next = last;
		}
		else {
			while (n->next && v >= n->next->value)
				n = n->next;
			last->set(v, n, n->next);
			n->next = last;
			if (last->next)
				last->next->prev = last;
		}
		++last;
	}

	inline void push_sorted (int v) {
		push_sorted (v, first);
	}
};


List list;


int main ()
{
	Node *median;
	int numbers, v;

	list.clear();

	get_int(v);
	list.push(v);
	numbers = 1;
	median = list.first;
	put_int(v);

	while (get_int(v))
	{
		++numbers;
		list.push_sorted(v);
		switch (numbers % 2)
		{
			case 0:
			{
				if (v < median->value)
					median = median->prev;
				v = (median->value + median->next->value) / 2;
				put_int(v);
				break;
			}

			case 1:
			{
				if (v >= median->value)
					median = median->next;
				put_int(median->value);
				break;
			}
		}
	}

	return 0;
}